import React from 'react';
import ReactDOM from 'react-dom';
import RowInput from './Item/Input';
import RowSelect from './Item/Select';
import RowDate from './Item/DatePicker';
import {List} from 'antd-mobile';
import {getSA, getCoveragePeriod, getPaymentPeriod, getPayMode, getSocialInsurance, getPayMode25,YesNoEnum} from '../pages/product/staticData';
import Job from '../pages/product/job';

class Factor extends React.Component {
    constructor(props) {
		super(props);
        this.state = {
            
        }
    }
    
    componentDidMount() {
        
    }

    onChangeFactor = (obj) => {
        if(this.props.type == 9 && obj.damageLevel){
            this.props.callback && this.props.callback({occupation:obj.damageLevel},this.props.index);
            return;
        }
        console.log(this.props.index);
        this.props.callback && this.props.callback(obj,this.props.index);
    }

    // 缴费年数--2
    getPaymentPeriod2 = () => {
        const list = [
            {
                label: '趸缴',
                value: '0',
            },{
                label: '3年',
                value: '3',
            },{
                label: '5年',
                value: '5',
            }  
        ]
        return list;
    }

    // 缴费年数--9
    getPaymentPeriod9 = () => {
        const list = [
            {
                label: '10年',
                value: '10',
            },{
                label: '20年',
                value: '20',
            },{
                label: '30年',
                value: '30',
            }  
        ]
        return list;
    }

    // 保障期间 --9
    getCoveragePeriod9 = () => {
        const list = [
            {
                label: '70年',
                value: '70',
            },{
                label: '80年',
                value: '80',
            },{
                label: '终身',
                value: '999',
            }  
        ]
        return list;
    }

    // 保障期间 --12
    getCoveragePeriod12 = () => {
        const list = [
            {
                label: '20年',
                value: '20',
            },{
                label: '30年',
                value: '30',
            } 
        ]
        return list;
    }

    getPayMode12 = () => {
        const list = [
            {
                label: window.LangMessage.year_pay || '年缴',
                value: 'YEAR',
            },{
                label: window.LangMessage.single || '趸缴',
                value: 'SINGLE',
            } 
        ]
        return list;
    }

    RenderDom = (type) => {
        const {SA, paymentPeriod, payFrequencyType, coveragePeriod, socialInsurance, unit} = this.props;
        switch(type){
            case '1':
            return (<List>
                    <RowSelect label={window.LangMessage.social_insurance || 'SocialInsurance'} name="socialInsurance" language='English' value={socialInsurance} data={getSocialInsurance()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '2':
            return (<List>
                    <RowSelect label={window.LangMessage.Payment_Period || '繳費年限'} name="paymentPeriod" value={paymentPeriod} data={this.getPaymentPeriod2()} callback={this.onChangeFactor} />
                    <RowInput label={window.LangMessage.unit || "份数"} name="unit"  value={unit} callback={this.onChangeFactor} />
                </List>)
                break;
            case '9':
            return (<List>
                    <RowSelect label={window.LangMessage.Payment_Period || '繳費年限'} name="paymentPeriod" value={paymentPeriod} data={this.getPaymentPeriod9()} callback={this.onChangeFactor} />
                    <RowSelect label={window.LangMessage.coverage_period || "保障期間"} name="coveragePeriod" value={coveragePeriod} data={this.getCoveragePeriod9()} callback={this.onChangeFactor} />
                    <RowInput label={window.LangMessage.unit || "份数"} name="unit"  value={unit} callback={this.onChangeFactor} />
                    <Job callback={this.onChangeFactor} />
                </List>)
                break;
            case '12':
            return (<List>
                    <RowSelect label={window.LangMessage.Payment_Period || '繳費年限'} name="paymentPeriod" value={paymentPeriod} data={this.getPaymentPeriod2()} callback={this.onChangeFactor} />
                    <RowSelect label={window.LangMessage.coverage_period || "保障期間"} name="coveragePeriod" value={coveragePeriod} data={this.getCoveragePeriod12()} callback={this.onChangeFactor} />
                    <RowSelect label={window.LangMessage.pay_frequency_text || "繳別"} name="payFrequencyType" value={payFrequencyType} data={this.getPayMode12()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '20':
            return (<List>
                    <RowSelect label="Social Insurance" name="socialInsurance" language='English' value={socialInsurance} data={getSocialInsurance()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '10':
                return (<List>
                    <RowSelect label="Social Insurance" name="socialInsurance" language='English' value={socialInsurance} data={getSocialInsurance()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '21':
                return (<List>
                    <RowSelect label="Social Insurance" name="socialInsurance" language='English' value={socialInsurance} data={getSocialInsurance()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '112001':
                return (<List>
                    <RowSelect label={window.LangMessage.social_insurance || "社保"} name="socialInsurance"  value={socialInsurance} data={YesNoEnum()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '25':
                return (<List>
                    <RowSelect label={window.LangMessage.pay_type || "繳別"} name="payFrequencyType" value={payFrequencyType} data={getPayMode25()} callback={this.onChangeFactor} />
                </List>)   
                break;
            case '13':
                return (<List>
                    {/* <RowSelect label="保额" name="SA" value={SA} data={getSA()} callback={this.onChangeFactor} /> */}
                    <RowSelect label={window.LangMessage.coverage_period || "保障期間"} name="coveragePeriod" value={coveragePeriod} data={getCoveragePeriod()} callback={this.onChangeFactor} />
                </List>)
                break;
            case '14':
                return (<List>
                    {/* <RowSelect label="保额" name="SA" value={SA} data={getSA()} callback={this.onChangeFactor} /> */}
                </List>)
                break;
            case '15':
                return (<List>
                    {/* <RowSelect label="保额" name="SA" value={SA} data={getSA()} callback={this.onChangeFactor} /> */}
                    {/* <RowSelect label="繳費年限" name="paymentPeriod" value={paymentPeriod} data={getPaymentPeriod()} callback={this.onChangeFactor} /> */}
                    <RowSelect label={window.LangMessage.pay_type || "繳別"} name="payFrequencyType" value={payFrequencyType} data={getPayMode()} callback={this.onChangeFactor} />
                </List>);
                break;
            case '42003':            
                return (<List>                    
                    <RowSelect label={window.LangMessage.pay_type || "繳別"} name="payFrequencyType" value={payFrequencyType} data={getPayMode()} callback={this.onChangeFactor} />
                </List>);
                break;
        }
    }

    render() {
        const {type} = this.props;
        console.log(type);
        return (
            <div>
                {this.RenderDom(type)}
            </div>
        )
    }
}

export default Factor;